package gicom;

import org.omg.PortableServer.ForwardRequest;
import org.omg.PortableServer.POA;
import org.omg.PortableServer.Servant;
import org.omg.PortableServer.ServantActivatorPOA;

public class GenericActivator extends ServantActivatorPOA {
    
    public GenericActivator() {
        super();
    }
    
    public Servant incarnate(byte[] id, POA poa) throws ForwardRequest {
        try {
            System.out.println("Incarnate object " + new String(id));
            return GenericServer.defaultGenericServer.getGenericManager().recreateObject(new String(id));
        } catch (Exception ex) {
            ex.printStackTrace();
            throw new ForwardRequest();
        }
    }

    @Override
    public void etherealize(byte[] id, POA poa, Servant servant, boolean cleanup_in_progress, boolean remaining_activations) {
        try {
            System.out.println("etherealize object " + new String(id));
            GenericServer.defaultGenericServer.getGenericManager().saveObject(new String(id));
        } catch (Exception ex) {
            
        }
    }
}
